package demo5;
/*

class Animal {
    public String name;
    public int age;

    static {
        System.out.println("父类静态代码块");
    }

    {
        System.out.println("父类实例代码块");
    }

    public Animal(String name, int age) {
        this.name = name;
        this.age = age;
        System.out.println("父类构造函数");
    }

    public void eat() {
        System.out.println(this.name + "正在吃饭!");
    }

    public void sleep() {
        System.out.println(name + "正在睡觉");
    }
}

class Dog extends Animal {
    public void bark() {
        System.out.println(this.name + "正在汪汪叫！");
    }

    public Dog(String name, int age) {
        super(name, age);
    }
}

class Cat extends Animal {
    public void mew() {
        System.out.println(this.name + "正在喵喵叫！");
    }

    public Cat() {
        super("圆圆", 10);
    }
}

public class Test {
    public static void main(String[] args) {
        Dog dog = new Dog("圆圆", 10);
    }
}
*/


class Base {
    static {
        System.out.println("父类静态代码块");
    }
    {
        System.out.println("父类实例代码块");
    }
    public Base() {
        System.out.println("父类构造函数");
    }
}
class Derived extends Base {
    static {
        System.out.println("子类静态代码块");
    }
    {
        System.out.println("子类实例代码块");
    }
    public Derived() {
        super();
        System.out.println("子类构造函数");
    }
}
public class Test {
    public static void main(String[] args) {
        Derived derived = new Derived();
        System.out.println("======================");
        Derived derived2 = new Derived();
    }
}
